import {WidgetClass} from "../atom/widget";

export class SipCall extends WidgetClass {
  constructor(options = {}) {
    super(options);
    const {ports, UI} = options;
    if (UI) {
      this.UI.data = UI.data;
    } else {
      this.UI.data = {
        textSize:16,
        iconSize:40,
        useManagerData:false,
        sipData:{
          phoneNumber:'',
          password:'',
          serviceAddress:'',
          tcpAddress:'',
          callNumber:'',
        }
      };
    }
    if (ports) {
      this.ports = ports;
    } else {
      this.ports = this.assembleDefaultPorts();
    }
  }
  assembleDefaultState(options = {}) {
    const superState = super.assembleDefaultState(options);
    return {
      ...superState,
    };
  }

  assembleDefaultPorts() {
    const superState = super.assembleDefaultPorts();
    return {
      ...superState,
      values: [
        ...superState.values,
        {
          name: "服务地址",
          key: "sipServerAddr",
          type: "string",
          value: "",
        },
        {
          name: "代理地址",
          key: "sipProxy",
          type: "string",
          value: "",
        },
        {
          name: "密码",
          key: "sipAccPwd",
          type: "string",
          value: "",
        },
        {
          name: "被呼号码",
          key: "callNumber",
          type: "string",
          value: "",
        },
      ],
      events: [
        ...superState.events,
      ],
    };
  }
}
